<?php 
namespace app\common\model;
class Category extends Common{
	protected $insert = ['addtime'=>SYS_TIME];
	protected function getPnameAttr($value,$data){
		return $data['pid'] ? $this->where("id",$data['pid'])->value("title") : '顶级分类';
	}
	protected function getStatusnameAttr($value, $data){
		$status = [0=>'隐藏',1=>'显示'];
		return $status[$data['status']];
	}
	protected function getAddtimeAttr($value){
		return date("Y-m-d H:i:s",$value);
	}
	protected function getThumbAttr($value){
		if(strpos($value,"http://") !== false){
			return $value;
		}
		else{
			return $value ? rtrim(APP_URL,"/").'/'.$value : '';
		}
	}
	protected function getUrlAttr($value, $data){
		return APP_URL.'/index/index/lists/catid/'.$data['id'];
	}
	protected function getAlldataAttr($value, $data){
		$arr = [0=>'隐藏',1=>'显示'];
		$data['statusname'] = $arr[$data['status']];
		$data['pname'] = $data['pid'] ? $this->where("id",$data['pid'])->value("title") : '顶级分类';
		$data['addtime'] = date("Y-m-d H:i:s", $data['addtime']);
		return $data;
	}
}